#!/bin/sh
# 基于ubuntu2004的版本
# 下载地址: https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-desktop-amd64.iso
# sudo sh initUbuntu.sh > init.log

echo $(lsb_release -c --short)
# 更换源
mv /etc/apt/sources.list /etc/apt/sources.list.bak
wget https://gitee.com/mezhou887/portainer/raw/master/source-2004.list -O /etc/apt/sources.list
/bin/sh /usr/lib/apt/apt.systemd.daily update
apt-get update
apt-get install -y openssh-server net-tools vim zip unzip curl git redis-server ufw autojump maven nginx nodejs npm openjdk-8-jdk default-jre default-jdk screen jq zookeeper mongodb gparted sendemail lrzsz tomcat9 tomcat9-docs tomcat9-examples tomcat9-admin uidmap mysql-server mysql-client
apt-get -y upgrade

# openssh-server
sed -ri 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sed -ri 's/#PermitRootLogin yes/PermitRootLogin yes/' /etc/ssh/sshd_config
/etc/init.d/ssh restart

# mysql
# sudo mysql_secure_installation
/etc/init.d/mysql restart

# mongodb
/etc/init.d/mongodb restart

# maven
mkdir -p /tools/repository
mv /etc/maven/settings.xml /etc/maven/settings.xml.bak
wget https://gitee.com/mezhou887/portainer/raw/master/settings.xml -O /etc/maven/settings.xml

# 安装zerotier
curl -s https://install.zerotier.com | bash
# zerotier-cli join a84ac5c10a09fd21

# docker
# apt-get install -y uidmap
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
# dockerd-rootless-setuptool.sh install
# export PATH=/usr/bin:$PATH
# export DOCKER_HOST=unix:///run/user/1000/docker.sock
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data cr.portainer.io/portainer/portainer-ce:latest
wget https://gitee.com/mezhou887/portainer/raw/master/dockerimage.sh -O /tmp/dockerimage.sh
#sh /tmp/dockerimage.sh


ufw disable
ufw status

apt-get autoremove
apt-get autoclean

# reboot
